package edu.hawaii.senin.iclouds.simple;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import edu.hawaii.senin.iclouds.basics.ReadConfigException;

/**
 * Tests cloud physical parameters operations.
 * 
 * @author Pavel Senin.
 * 
 */
public class TestCloudParametersMessage {

  /**
   * Tests correct operations.
   * 
   * @throws ReadConfigException if an error encountered.
   * 
   */
  @Test
  public void testPhysicalParameters() throws ReadConfigException {
    Cloud cloud = new Cloud();

    CloudParametersMessage cmIn = new CloudParametersMessage();

    cmIn.addParameter(CloudParametersMessage.TEMPERATURE, "100.0");
    cmIn.addParameter(CloudParametersMessage.DENSITY, "101.0");
    cmIn.addParameter(CloudParametersMessage.SITESNUM, "102");
    cmIn.addParameter(CloudParametersMessage.GRAINSIZE, "103");
    cmIn.addParameter(CloudParametersMessage.DHRATIO, "0.01");
    cmIn.addParameter(CloudParametersMessage.BURY, "true");
    cmIn.addParameter(CloudParametersMessage.CASCADE, "true");
    cmIn.addParameter(CloudParametersMessage.ITRLIMIT, "104");
    cmIn.addParameter(CloudParametersMessage.ACCSTEP, "105");
    cmIn.addParameter(CloudParametersMessage.CFGNAME, "config/test_cfg/test_cfg01.xml");
    cmIn.addParameter(CloudParametersMessage.LOGNAME, "output/test_out/test_out1.log");
    cmIn.addParameter(CloudParametersMessage.LOGGERNAME, "output/test_out/test_out2.log");
    cmIn.addParameter(CloudParametersMessage.LOGGERTYPE, "xml");
    cmIn.addParameter(CloudParametersMessage.LOGGERLEVEL, "fine");

    cloud.setParameters(cmIn);

    CloudParametersMessage cmOut = cloud.getCloudParameters();

    assertEquals("", "100.0", cmOut.get(CloudParametersMessage.TEMPERATURE));
    assertEquals("", "101.0", cmOut.get(CloudParametersMessage.DENSITY));
    assertEquals("", "102", cmOut.get(CloudParametersMessage.SITESNUM));
    assertEquals("", "103.0", cmOut.get(CloudParametersMessage.GRAINSIZE));
    assertEquals("", "0.01", cmOut.get(CloudParametersMessage.DHRATIO));
    assertEquals("", "true", cmOut.get(CloudParametersMessage.BURY));
    assertEquals("", "true", cmOut.get(CloudParametersMessage.CASCADE));
    assertEquals("", "104", cmOut.get(CloudParametersMessage.ITRLIMIT));
    assertEquals("", "105", cmOut.get(CloudParametersMessage.ACCSTEP));
    assertEquals("", "config/test_cfg/test_cfg01.xml", cmOut.get(CloudParametersMessage.CFGNAME));
    assertEquals("", "output/test_out/test_out1.log", cmOut.get(CloudParametersMessage.LOGNAME));
    assertEquals("", "output/test_out/test_out2.log", cmOut.get(CloudParametersMessage.LOGGERNAME));
    assertEquals("", "xml", cmOut.get(CloudParametersMessage.LOGGERTYPE));
    assertEquals("", "FINE", cmOut.get(CloudParametersMessage.LOGGERLEVEL));

  }

}
